import { Module } from '@nestjs/common';
import { RoomService } from './room.service';
import { RoomController } from './room.controller';
import { MulterModule } from '@nestjs/platform-express';
import { TypeOrmModule } from '@nestjs/typeorm';
import { diskStorage } from 'multer';
import { extname, join } from 'path';
import { Photo } from 'src/common/entities/photo.entity';
import { Room } from './entities/room.entity';
@Module({
  imports: [
    TypeOrmModule.forFeature([Room, Photo]),
    MulterModule.register({
      storage: diskStorage({
        destination: join(__dirname, '../static'),
        filename: (_, file, callback) => {
          const fileName = `${
            new Date().getTime() + extname(file.originalname)
          }`;
          return callback(null, fileName);
        },
      }),
    }),
  ],
  controllers: [RoomController],
  providers: [RoomService],
})
export class RoomModule {}
